﻿.table-fixed-header .table thead tr th.dropdown-table-fixed-header-visible {
    z-index: 11;
}

.dropdown-menu-position-strategy {
    width: max-content;
    top: 0;
    left: 0;
}

.dropdown-menu-position-strategy-absolute {
    position: absolute;
}

.dropdown-menu-position-strategy-fixed {
    position: fixed;
}

.dropdown-toggle.dropdown-toggle-hidden::after {
    content: none !important;
}

.dropdown-toggle.dropdown-toggle-hidden::before {
    content: none !important;
}

.dropdown-menu.show {
    animation-duration: 0.3s;
    animation-fill-mode: both;
    animation-name: fadeIn;
}

.dropdown-menu a:not([href]).dropdown-item:not(.disabled) {
    cursor: pointer;
}

.dropdown-menu.dropdown-menu-scrollable {
    max-height: var(--dropdown-list-menu-max-height, 200px);
    overflow-y: scroll;
}

.b-is-autocomplete .dropdown-menu {
    width: 100%;
    max-height: var(--autocomplete-menu-max-height, 200px);
    overflow-y: scroll;

    .dropdown-item.focus {
        color: #1e2125 !important;
        background-color: #e9ecef;
    }
}

.b-is-autocomplete.b-is-autocomplete-multipleselection {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    max-width: 100%;
    width: 100%;
    cursor: text;
    min-height: calc(1.5em + .75rem + 2px);
    height: auto;
    border: $input-border-width solid $input-border-color;
    border-radius: $input-border-radius;

    > input.form-control:not(.is-valid, .is-invalid) {
        border: none;
    }

    > input.form-control {
        display: inline-block;
        box-shadow: none;
        outline: none;
        background-color: transparent;
        max-width: inherit;
        width: auto;
        flex-grow: 1;
    }

    > .badge {
        margin-top: 0.25rem;
        margin-bottom: 0.25rem;
        line-height: 1.5;
        flex-grow: initial;
    }

    .dropdown-menu {
        top: 100%;
    }

    @include form-control-focus
}

.dropdown.btn-group {
    > .btn.dropdown-toggle-split + .dropdown-menu.show {
        top: 100%;
    }
}

.dropdown {
    position: relative;

    .btn.dropdown-toggle:not(.btn-outline) {
        box-shadow: none;
        border: none;
    }

    &.dropdown-disabled.b-is-autocomplete {
        background-color: var(--b-theme-light, #e9ecef);
    }

    > .dropdown-menu {
        > .dropdown:not(.dropup, .dropstart, .dropend) {
            position: relative;

            > .dropdown-toggle {
                width: 100%;
                @include caret(down);

                &::after {
                    position: absolute;
                    right: 10%;
                    top: 45%;
                }
            }

            > .dropdown-menu {
                top: auto;
                left: auto;
                bottom: auto;
                right: auto;
            }
        }

        > .dropdown.dropup, > .dropdown.dropend {
            .dropdown-toggle::after {
                vertical-align: 0;
                position: absolute;
                right: 10%;
                top: 45%;
            }
        }

        > .dropdown.dropstart {
            .dropdown-toggle::after {
                vertical-align: 0;
            }
        }
    }

    &.dropup {
        > .dropdown-menu {
            top: auto;
            bottom: auto;
            margin-top: 0;
            margin-bottom: $dropdown-spacer;
        }

        > .dropdown-toggle {
            @include caret(up);
        }
    }

    &.dropend {
        > .dropdown-menu {
            top: 0;
            right: auto;
            left: 100%;
            margin-top: 0;
            margin-left: $dropdown-spacer;
        }

        > .dropdown-toggle {
            @include caret(right);

            &::after {
                vertical-align: 0;
            }
        }
    }

    &.dropstart {
        > .dropdown-menu {
            top: 0;
            right: 100%;
            left: auto;
            margin-top: 0;
            margin-right: $dropdown-spacer;
        }

        > .dropdown-toggle {
            @include caret(left);

            &::before {
                vertical-align: 0;
            }
        }
    }
}

@each $breakpoint in map-keys($grid-breakpoints) {
    @include media-breakpoint-up($breakpoint) {
        $infix: breakpoint-infix($breakpoint, $grid-breakpoints);

        .dropdown-menu#{$infix}-start {
            right: auto;
            left: 0;
        }

        .dropdown-menu#{$infix}-end {
            right: 0;
            left: auto;
        }
    }
}
